const api_url = "http://127.0.0.1";

const serve = ({ url, data, method }): any => {
	return new Promise((res, rej) => {
		uni.request({
			method,
			url: `${api_url}${url}`, //仅为示例，并非真实接口地址。
			data,
			success: ({ data }: { data: Types.Http.Response<any> }) => {
				// 拦截器
				switch (data.code) {
					case 1:
						break;
					case 0:
						break;
					case 304:
						break;
					default:
						break;
				}
				res(data);
			},
			fail: (resp) => {
				rej(resp);
			}
		});
	});
};

export default serve;
